#include <bits/stdc++.h>

using namespace std;
const int N=100005;

struct car{
    int d_0,v_0,a;
}b[N];
int n,m,L,V,p[N],ilg[N],irg[N],f[N];

void solve(){
    cin>>n>>m>>L>>V;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        cin>>b[i].d_0>>b[i].v_0>>b[i].a;
        sum1+=b[i].a;
        sum2+=abs(b[i].a);
    }
    for(int i=0;i<m;i++)cin>>p[i];
    memset(ilg,-1,sizeof(ilg));
    int ans=0;
    if(sum2==0){
        for(int i=0;i<n;i++){
            if(b[i].v_0>V){
                int k=lower_bound(p,p+m,b[i].d_0)-p;
                if(k!=m){ans++;ilg[i]=k;}
//                cout<<i<<" # "<<k<<endl;
            }
        }
        if(ans==0)cout<<"0 0\n";
        else cout<<ans<<" "<<"1\n";
    }
    else if(sum2==sum1){
        for(int i=0;i<n;i++){
            double x=b[i].d_0;
            if(b[i].v_0<=V&&b[i].a>0)x+=(V*V-b[i].v_0*b[i].v_0)/(2*b[i].a)+1;
            if(x>(double)L)continue;
            int k=lower_bound(p,p+m,x)-p;
            if(k!=m){ans++;ilg[i]=k;}
//            cout<<x<<" # "<<i<<" # "<<k<<endl;
        }
        if(ans==0)cout<<"0 0\n";
        else cout<<ans<<" "<<"1\n";
    }
    else{
        int cnt=0;
        for(int i=0;i<n;i++){
            if(b[i].a==0&&b[i].v_0>V){
                int k=lower_bound(p,p+m,b[i].d_0)-p;
                if(k!=m){ans++;ilg[i]=k;}
            }else if(b[i].a>0){
                double x=b[i].d_0;
                if(b[i].v_0<=V)x+=(V*V-b[i].v_0*b[i].v_0)/(2*b[i].a)+1;
                if(x>(double)L)continue;
                int k=lower_bound(p,p+m,x)-p;
                if(k!=m){ans++;ilg[i]=k;irg[i]=L;}
            }else if(b[i].a<0&&b[i].v_0>V){
                ilg[i]=lower_bound(p,p+m,b[i].d_0)-p;
                if(b[i].d_0!=p[ilg[i]])ilg[i]++;
                double x=b[i].d_0+(double)(V*V-b[i].v_0*b[i].v_0)/(2*b[i].a)+1;
                x=min(x,(double)L);
                irg[i]=lower_bound(p,p+m,x)-p;
                if(b[i].d_0>p[ilg[i]]&&x<(double)p[irg[i]])f[i]=1;
                if(f[i])ans++,cnt++;
//                cout<<x<<" # "<<ilg[i]<<" # "<<irg[i]<<" # "<<i<<endl;
            }
        }
        cout<<ans<<" "<<1+cnt<<endl;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}